"use strict";
cc._RF.push(module, '1c90cgyszpAyad2UJYX3G1K', 'EquipViewUI');
// scripts/EquipViewUI.js

"use strict";

var e = require;
var t = module;
var o = exports;

var _ii,
    nn = void 0 && (void 0).__extends || (_ii = function ii(t, e) {
  return (_ii = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (t, e) {
    t.__proto__ = e;
  } || function (t, e) {
    for (var o in e) {
      Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
  })(t, e);
}, function (t, e) {
  function o() {
    this.constructor = t;
  }

  _ii(t, e), t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o());
}),
    rr = void 0 && (void 0).__awaiter || function (t, e, o, i) {
  return new (o || (o = Promise))(function (n, a) {
    function r(t) {
      try {
        l(i.next(t));
      } catch (e) {
        a(e);
      }
    }

    function s(t) {
      try {
        l(i["throw"](t));
      } catch (e) {
        a(e);
      }
    }

    function l(t) {
      var e;
      t.done ? n(t.value) : (e = t.value, e instanceof o ? e : new o(function (t) {
        t(e);
      })).then(r, s);
    }

    l((i = i.apply(t, e || [])).next());
  });
};

var oo = void 0 && (void 0).__decorate || function (e, t, a, n) {
  var i,
      o = arguments.length,
      s = o < 3 ? t : null === n ? n = Object.getOwnPropertyDescriptor(t, a) : n;
  if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, a, n);else for (var r = e.length - 1; r >= 0; r--) {
    (i = e[r]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, a, s) : i(t, a)) || s);
  }
  return o > 3 && s && Object.defineProperty(t, a, s), s;
};

Object.defineProperty(o, "__esModule", {
  value: !0
});

var a = e("BaseModuleUI"),
    n = e("NotifyEventType"),
    i = e("AssetsManager"),
    r = e("EquipInfo"),
    s = e("equip_item_info"),
    l = cc._decorator,
    _ = l.ccclass,
    c = l.property,
    d = function (e) {
  function t() {
    var t = null !== e && e.apply(this, arguments) || this;
    return t.equip_item = null, t.equip_view = null, t.btn_view = null, t.equip_name_label = null, t.equip_icon_sprite = null, t.int_info_node = null, t.equip_skill_list = [], t.equip_type = ["att", "hp", "speed", "cool"], t;
  }

  return nn(t, e), t.prototype.initView = function () {
    e.prototype.initView.call(this);

    for (var t = 0; t < 3; t++) {
      for (var o = 0; o < 4; o++) {
        cc.instantiate(this.equip_item).setParent(this.equip_view.children[t]);
      }
    }

    this.attachEvent(n["default"].SEND_CHOOSE_EQUIP_INFO, this.showChooseEquipInfo, this), this.showEquipViewInfo("att");
  }, t.prototype.OnClick = function (t) {
    switch (e.prototype.OnClick.call(this, t), t.node.name) {
      case "equip_att_btn":
        this.showEquipViewInfo("att");
        break;

      case "equip_hp_btn":
        this.showEquipViewInfo("hp");
        break;

      case "equip_speed_btn":
        this.showEquipViewInfo("speed");
        break;

      case "equip_cooling_btn":
        this.showEquipViewInfo("cool");
    }
  }, t.prototype.showEquipViewInfo = function (e) {
    for (var t = 0; t < 4; t++) {
      this.btn_view.children[t].children[0].active = e == this.equip_type[t];
    }

    var o = [];

    for ("att" == e ? o = r["default"].equip_att_info : "hp" == e ? o = r["default"].equip_hp_info : "speed" == e ? o = r["default"].equip_speed_info : "cool" == e && (o = r["default"].equip_cooling_info), t = 0; t < 3; t++) {
      for (var a = 0; a < 4; a++) {
        this.equip_view.children[t].children[a].active = !1;
      }
    }

    for (t = 0; t < o.length; t++) {
      var i = r["default"].eqquip_info[o[t]],
          l = this.equip_view.children[i.eq_level - 1].children[i.eq_index];
      l.getComponent(s["default"]).showEquipInfo(i), l.active = !0;
    }

    this.emitEvent(n["default"].SEND_CHOOSE_EQUIP_INFO, {
      use: !1,
      info: r["default"].eqquip_info[o[0]]
    });
  }, t.prototype.showChooseEquipInfo = function (e, t) {
    var o = t.info;
    this.equip_name_label.string = "" + o.eq_name, this.equip_icon_sprite.spriteFrame = i["default"].getInstance().getEquipIconFrame("equip_" + o.eq_ID);

    for (var a = 0; a < this.equip_skill_list.length; a++) {
      this.equip_skill_list[a].active = o.eq_skill[a], this.equip_skill_list[a].active && (this.equip_skill_list[a].getChildByName("type").getComponent(cc.Label).string = o.eq_skill[a], this.equip_skill_list[a].getChildByName("info").getComponent(cc.Label).string = o.eq_skill_des[a]);
    }

    for (a = 0; a < 2; a++) {
      this.int_info_node.children[a].active = o.eq_int[a], this.int_info_node.children[a] && (this.int_info_node.children[a].children[0].getComponent(cc.Label).string = o.eq_int[a]);
    }
  }, oo([c(cc.Node)], t.prototype, "equip_item", void 0), oo([c(cc.Node)], t.prototype, "equip_view", void 0), oo([c(cc.Node)], t.prototype, "btn_view", void 0), oo([c(cc.Label)], t.prototype, "equip_name_label", void 0), oo([c(cc.Sprite)], t.prototype, "equip_icon_sprite", void 0), oo([c(cc.Node)], t.prototype, "int_info_node", void 0), oo([c(cc.Node)], t.prototype, "equip_skill_list", void 0), oo([_], t);
}(a["default"]);

o["default"] = d;

cc._RF.pop();